<%@page import="com.tangtang.core.RequestUtil" %>
<%@page import="java.util.List" %>
<%@page import="com.tangtang.security.view.model.SysViewResource" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
    <div class="list-group" id="resourceTree">
        <%!
            private void printMenu(com.tangtang.core.tree.Tree<SysViewResource> tree, javax.servlet.jsp.JspWriter out,int currentResourceId) throws java.io.IOException, ServletException {
                out.print("<a href=\'#\' data=\""+tree.getValue().getResourceId()+"\" class=\"list-group-item\">");
                for (int i = 0; i < tree.getValue().getDepth(); i++) {
                    out.print("&nbsp;&nbsp;&nbsp;&nbsp;");
                }
                out.print(tree.getValue().getResourceName());
                out.print("</a>");
                out.println();
                if (tree.getChildren() != null) {
                    for (com.tangtang.core.tree.Tree<SysViewResource> resource : tree.getChildren()) {
                        printMenu(resource, out, currentResourceId);
                    }
                }
            }
        %>
        <%
            List<com.tangtang.core.tree.Tree<SysViewResource>> list = (List<com.tangtang.core.tree.Tree<SysViewResource>>) request.getAttribute("tree");
            if (list != null) {
                int resourceid = RequestUtil.getInt("resourceid");
                for (com.tangtang.core.tree.Tree<SysViewResource> tree : list) {
                    printMenu(tree, out, resourceid);
                }
            }
        %>
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
<script type="text/javascript">
    $("#resourceTree a").each(function(){
        $(this).bind("click",function(){
            $("input[name='resourceParentId']").val($(this).attr("data"));
            $("input[name='txtResourceParentId']").val($(this).html().replace(/&nbsp;/ig,""));
            $('#helpModal').modal('hide');
        });
    });
</script>